<!DOCTYPE html>
<html>
<head>
	<title></title>
	<base href="http://localhost/">
	<link rel="stylesheet" type="text/css" href="layui/css/layui.css">
	<script type="text/javascript" src="layui/layui.js"></script>
</head>
<body style="padding: 10px">
	<form method="post" action="<?=site_url('/Main/user_add')?>" name="userform">
		<div class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="username">
				</div>
			</div>

			<div class="layui-form-item">
			<label class="layui-form-label">密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input" name="userpassword">
			</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">角&nbsp;&nbsp;&nbsp;&nbsp;色</label>
				<div class="layui-input-inline">
					<select class="" name="userorle">
						<!-- 1学生 2老师 3游客 -->						
						<option value="1">学生</option>
						<option value="2">老师</option>
						<option value="3">游客</option>
					</select>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">状&nbsp;&nbsp;&nbsp;&nbsp;态</label>
				<div class="layui-input-inline">
					<input type="checkbox" lay-skin="primary" value="1" name="userstate" title="禁用">
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" onclick="return check(userform)">保存</button>
					<button  class="layui-btn" onclick="cheremove()">取消</button>
				</div>
			</div>

		</div>
	</form>

	<script type="text/javascript">
		layui.use(['layer','form'],function(){
			form = layui.form;
			layer = layui.layer;
			$ = layui.jquery;
		});
		function cheremove(){
			var mylay = parent.layer.getFrameIndex(window.name);
			parent.layer.close(mylay);
		};
		function check(form){
			if(form.username.value == ""){
				alert("用户名不能为空");
				form.username.focus();
				return false;
			}
			if(form.userpassword.value == ""){
				alert("密码不能为空");
				form.userpassword.focus();
				return false;
			}
			var mylay = parent.layer.getFrameIndex(window.name);
			parent.layer.close(mylay);

			//提交完成关闭模态框
			// layer.msg("保存完成");
			// setTimeout(function(){parent.window.location.reload();},1000);
			// parent.window.location.reload();
		}
	</script>
</body>
</html>